var dateTime = {

	html: function (timeTypeArray) {
    var timeType = {
      HourTimeType: '时',
      DayTimeType: '日',
      HouTimeType: '候',
      TenDaysTimeType: '旬',
      MonthTimeType: '月',
      SeasonTimeType: '季',
      YearTimeType: '年',
      WeekTimeType:'周'
    };
    var html="<div class=\"pluginsDiv\" id='dateTimeDiv'>";
    var timeTypeHtml="<div class=\"pluginsSingleRows time-type layui-form-item\">" +
      "<label class='layui-form-label'>时间类型:</label>" +
      "<div class='layui-input-block'>" +
      "<select lay-filter='timeTypeSelect' id='timeTypeSelect'>";
    for(var i=0;i<timeTypeArray.length;i++){
      timeTypeHtml+="<option value=\""+timeTypeArray[i]+"\"  >"+ timeType[timeTypeArray[i]] +"</option>";
    }
    timeTypeHtml+="</select></div></div>";
    html+=timeTypeHtml;

    /*时选择*/
    html += this.timeTemplate.hourTimeString();
    /*日选择*/
    html += this.timeTemplate.dayTimeString();
    /*候选择*/
    html += this.timeTemplate.houTimeString();
    /*旬时间选择*/
    html += this.timeTemplate.tenTimeString();
    /*月*/
    html += this.timeTemplate.monthTimeString();
    /*季度*/
    html += this.timeTemplate.seasonTimeString();
    /*年*/
    html += this.timeTemplate.yearTimeString();
    /*周选择*/
    html += this.timeTemplate.weekTimeString();
    if(Global.dataEnv  == "Forecast")
    html += this.timeTemplate.validTimeString();

    


    html+='</div>';
    return html;
  },
  getWeekOfYear : function(){
    var today = new Date();
      var firstDay = new Date(today.getFullYear(),0, 1);
      var dayOfWeek = firstDay.getDay(); 
      var spendDay= 1;
      if (dayOfWeek !=0) {
        spendDay=7-dayOfWeek+1;
      }
      firstDay = new Date(today.getFullYear(),0, 1+spendDay);
      var d =Math.ceil((today.valueOf()- firstDay.valueOf())/ 86400000);
      var result =Math.ceil(d/7);
      return result+1;
  },
  getWeekDates : function(currentTime){
    var currentDate = new Date(currentTime)
    var timesStamp = currentDate.getTime();
    var currenDay = currentDate.getDay();
    var dates = [];
    for (var i = 0; i < 7; i++) {
        dates.push(new Date(timesStamp + 24 * 60 * 60 * 1000 * (i - (currenDay + 6) % 7)).toLocaleDateString().replace(/\//g, '-'));
    }
    return dates
  },
  dateFromWeek : function(year,week,day){
    var   date1   =   new   Date(year,0,1);   
    var   dayMS   =   24*60*60*1000;   
    var   firstDay   =   (7-date1.getDay())*dayMS;   
    var   weekMS   =   (week-2)*7*dayMS;   
    var   result   =   date1.getTime()+firstDay+weekMS+day*dayMS;   
    date1.setTime(result);   
    return   date1; 
  },
	getData: function () {
	  var timeType = $('#timeTypeSelect').val();
	  /*判断时间条件*/
	  function timeJudge (start, end, interval, rangeString) {
      if ( new Date(start) - new Date(end) > 0 ) {
        layLayer.msg('开始时间不能大于结束时间', {icon: 7, time: 1500});
        Global.requestJudge = false;
      }

      /*/!*取消时间限制*!/
      else if ( new Date(end) - new Date(start) > interval) {
        layLayer.msg('查询时间不能大于'+ rangeString, {icon: 7, time: 1500});
        Global.requestJudge = false;
      }*/
    }

	  var start = '',
        end = '';
	  switch (timeType) {
      case 'HourTimeType':
        var startTimeHour = $('.HourTimeType .start-time-hour').val(),
          endTimeHour = $('.HourTimeType .end-time-hour').val();
        start = startTimeHour.replace(/[年月]/g, '-').replace('日', ' ').replace('时', '') + ':00';
        end = endTimeHour.replace(/[年月]/g, '-').replace('日', ' ').replace('时', '') + ':00';

        timeJudge(start, end, 11*24*3600*1000, '十天');

        var tempStart = start,
            tempEnd = end;

        start = new Date(start).format('yyyyMMddhh');
        end = new Date(end).format('yyyyMMddhh');

        /*gis图形面板副标题时间判断*/
        if ( start === end ) {
          Global.gisTimeTitle = startTimeHour;
        } else{
          if ( new Date(tempEnd).getFullYear() > new Date(tempStart).getFullYear() ) {
            Global.gisTimeTitle = startTimeHour + ' - ' + endTimeHour;
          } else if ( new Date(tempEnd).getMonth() > new Date(tempStart).getMonth() ) {
            Global.gisTimeTitle = startTimeHour + ' - ' + endTimeHour.split('年')[1];
          } else if ( new Date(tempEnd).getDay() > new Date(tempStart).getDay() ) {
            Global.gisTimeTitle = startTimeHour + ' - ' + endTimeHour.split('月')[1];
          } else {
            Global.gisTimeTitle = startTimeHour + ' - ' + endTimeHour.split('日')[1];
          }
        }

        break;
      case 'DayTimeType':
        var startTimeDay = $('.DayTimeType .start-time').val(),
            endTimeDay = $('.DayTimeType .end-time').val();
        start = startTimeDay.replace(/[年月]/g, '-').replace('日', '');
        end = endTimeDay.replace(/[年月]/g, '-').replace('日', '');

        timeJudge(start, end, 11*24*3600*1000, '十天');

        start = start.replace(/-/g, '');
        end = end.replace(/-/g, '');

        /*gis图形面板副标题时间判断*/
        if ( start === end ) {
          Global.gisTimeTitle = startTimeDay;
        } else{
           if ( new Date(endTimeDay.replace(/[年月]/g, '-').replace('日', '')).getFullYear() > new Date(startTimeDay.replace(/[年月]/g, '-').replace('日', '')).getFullYear() ) {
             Global.gisTimeTitle = startTimeDay + ' - ' + endTimeDay;
           } else if ( new Date(endTimeDay.replace(/[年月]/g, '-').replace('日', '')).getFullYear() === new Date(startTimeDay.replace(/[年月]/g, '-').replace('日', '')).getFullYear() &&
             new Date(endTimeDay.replace(/[年月]/g, '-').replace('日', '')).getMonth() > new Date(startTimeDay.replace(/[年月]/g, '-').replace('日', '')).getMonth() ) {
             Global.gisTimeTitle = startTimeDay + ' - ' + endTimeDay.split('年')[1];
           } else {
             Global.gisTimeTitle = startTimeDay + ' - ' + endTimeDay.split('月')[1];
           }
        }

        break;
      case "WeekTimeType":
        var startTimeWeekYear = $('.HouTimeType .start-time-year').val(),
        endTimeWeekYear = $('.HouTimeType .end-time-year').val();
        start = new Date(startTimeWeekYear.replace('年',''));
        end = new Date(endTimeWeekYear.replace('年',''));
        var startWeek = $('.WeekTimeType .start-time-week').val(),
            endWeek = $('.WeekTimeType .end-time-week').val();

        start = start.getFullYear() + startWeek;
        end = end.getFullYear() + endWeek;

        /*gis图形面板副标题时间判断*/
        if ( start === end ) {
          Global.gisTimeTitle = startTimeWeekYear + startWeek + '周';
        } else {
          if ( Number( endTimeWeekYear.replace('年','') ) > Number( startTimeWeekYear.replace('年','') ) ) {
            Global.gisTimeTitle = startTimeWeekYear + startWeek + '周' + ' - ' + endTimeWeekYear + endWeek + '周';
          } else if ( Number( startTimeWeekYear.replace('年','') ) === Number( endTimeWeekYear.replace('年','') ) ) {
            Global.gisTimeTitle = startTimeWeekYear + startWeek + '周' + ' - ' + endWeek + '周';
          }
        }

        var yearInt = startTimeWeekYear.replace("年","");
        yearInt = parseInt(yearInt);
        var lastWeek1 = dateTime.dateFromWeek(yearInt, parseInt(startWeek) , 1);
        var lastWeek7 = dateTime.dateFromWeek(yearInt, parseInt(startWeek) , 7);
        var m1 =   lastWeek1.getMonth()+1; m1 = m1 < 10 ? "0"+m1 : m1;
        var d1 = lastWeek1.getDate(); d1 = d1 < 10 ? "0"+d1 : d1;
        var m7 =   lastWeek7.getMonth()+1; m7 = m7 < 10 ? "0"+m7 : m7;
        var d7 = lastWeek7.getDate(); d7 = d7< 10 ? "0"+d7 : d7;
        start = lastWeek1.getFullYear()+""+m1+""+d1;  
        end = lastWeek7.getFullYear()+""+m7+""+d7;  
      break;  
      
      case 'HouTimeType':

        var startTimeHouYear = $('.HouTimeType .start-time-year').val(),
            endTimeHouYear = $('.HouTimeType .end-time-year').val();
        start = new Date(startTimeHouYear.replace('年',''));
        end = new Date(endTimeHouYear.replace('年',''));

        var startHou = $('.HouTimeType .start-time-hou').val(),
            endHou = $('.HouTimeType .end-time-hou').val();

        timeJudge(start.getTime() + Number(startHou)*5*24*3600000, end.getTime() + Number(endHou)*5*24*3600000, 6*5*24*3600000, '五候');

        start = start.getFullYear() + startHou;
        end = end.getFullYear() + endHou;

        /*gis图形面板副标题时间判断*/
        if ( start === end ) {
          Global.gisTimeTitle = startTimeHouYear + startHou + '候';
        } else {
          if ( Number( endTimeHouYear.replace('年','') ) > Number( startTimeHouYear.replace('年','') ) ) {
            Global.gisTimeTitle = startTimeHouYear + startHou + '候' + ' - ' + endTimeHouYear + endHou + '候';
          } else if ( Number( startTimeHouYear.replace('年','') ) === Number( endTimeHouYear.replace('年','') ) ) {
            Global.gisTimeTitle = startTimeHouYear + startHou + '候' + ' - ' + endHou + '候';
          }
        }

        break;
      case 'TenDaysTimeType':
        var startTimeTen = $('.TenDaysTimeType .start-time-month').val(),
            endTimeTen = $('.TenDaysTimeType .end-time-month').val();
        start = new Date(startTimeTen.replace(/年/g, '-').replace('月', ''));
        end = new Date(endTimeTen.replace(/年/g, '-').replace('月', ''));

        var startMonth = $('.TenDaysTimeType .start-time-ten').val(),
            endMonth = $('.TenDaysTimeType .end-time-ten').val();

        timeJudge(start.getTime() + Number(startMonth)*10*24*3600000, end.getTime() + Number(endMonth)*10*24*3600000, 4*10*24*3600000, '三旬');

        start = start.format('yyyyMM') + startMonth;
        end = end.format('yyyyMM') + endMonth;

        var tenString = ['上旬', '中旬', '下旬'];
        if ( start === end ) {
          Global.gisTimeTitle = startTimeTen + tenString[Number(startMonth) - 1];
        } else {
          if ( new Date(endTimeTen.replace(/年/g, '-').replace('月', '')).getFullYear() > new Date(startTimeTen.replace(/年/g, '-').replace('月', '')).getFullYear() ) {
            Global.gisTimeTitle = startTimeTen + tenString[Number(startMonth) - 1] + ' - ' + endTimeTen + tenString[Number(endMonth) - 1];
          } else if (  new Date(endTimeTen.replace(/年/g, '-').replace('月', '')).getMonth() > new Date(startTimeTen.replace(/年/g, '-').replace('月', '')).getMonth()  ) {
            Global.gisTimeTitle = startTimeTen + tenString[Number(startMonth) - 1] + ' - ' + endTimeTen.split('年')[1] + tenString[Number(endMonth) - 1];
          } else {
            Global.gisTimeTitle = startTimeTen + tenString[Number(startMonth) - 1] + ' - ' + tenString[Number(endMonth) - 1];
          }
        }

        break;
      case 'MonthTimeType':

        var startTimeMon = $('.MonthTimeType .start-time-month').val(),
            endTimeMon = $('.MonthTimeType .end-time-month').val();
        start = new Date(startTimeMon.replace(/年/g, '-').replace('月', ''));
        end = new Date(endTimeMon.replace(/年/g, '-').replace('月', ''));

        timeJudge(start, end, 4*30*24*3600000, '三个月');

        start = start.format('yyyyMM');
        end = end.format('yyyyMM');

        if ( start === end ) {
          Global.gisTimeTitle = startTimeMon;
        } else {
          if ( new Date(endTimeMon.replace(/年/g, '-').replace('月', '')).getFullYear() > new Date(startTimeMon.replace(/年/g, '-').replace('月', '')).getFullYear() ) {
            Global.gisTimeTitle = startTimeMon + ' - ' + endTimeMon;
          } else if ( new Date(endTimeMon.replace(/年/g, '-').replace('月', '')).getMonth() > new Date(startTimeMon.replace(/年/g, '-').replace('月', '')).getMonth() ) {
            Global.gisTimeTitle = startTimeMon + ' - ' +endTimeMon.split('年')[1];
          }
        }

        break;
      case 'SeasonTimeType':
        var startTimeSea = $('.SeasonTimeType .start-time-year').val(),
            endTimeSea = $('.SeasonTimeType .end-time-year').val();
        start = new Date(startTimeSea.replace(/年/g, ''));
        end = new Date(endTimeSea.replace(/年/g, ''));

        var startSeason = $('.SeasonTimeType .start-time-season').val(),
            endSeason = $('.SeasonTimeType .end-time-season').val();

        timeJudge(start.getTime() + Number(startSeason)*90*24*3600000, end.getTime() + Number(endSeason)*90*24*3600000, 4*90*24*3600000, '三个季度');

        start = start.getFullYear() + startSeason;
        end = end.getFullYear() + endSeason;

        var seasonString = ['春季', '夏季', '秋季', '冬季'];
        if ( start === end ) {
          Global.gisTimeTitle = startTimeSea + seasonString[Number(startSeason) - 1];
        } else {
          if ( Number(endTimeSea.replace(/年/g, '')) > Number(startTimeSea.replace(/年/g, '')) ) {
            Global.gisTimeTitle = startTimeSea + seasonString[Number(startSeason) - 1] + ' - ' + endTimeSea + seasonString[Number(endSeason) - 1];
          } else {
            Global.gisTimeTitle = startTimeSea + seasonString[Number(startSeason) - 1] + ' - ' + seasonString[Number(endSeason) - 1];
          }
        }

        break;
      case 'YearTimeType':
        start = new Date($('.YearTimeType .start-time-year').val().replace(/年/g, ''));
        end = new Date($('.YearTimeType .end-time-year').val().replace(/年/g, ''));

        timeJudge(start, end, 4*365*24*3600000, '三年');

        start = start.getFullYear();
        end = end.getFullYear();

        if ( start === end ) {
          Global.gisTimeTitle = start + '年';
        } else {
          Global.gisTimeTitle = start + '年' + ' - ' + end + '年';
        }

        break;
    }
    Global.postData.startTime = start;
    Global.postData.endTime = end;


    Global.postData.businessTimeType = timeType == "WeekTimeType" ? "DayTimeType" : timeType;
    Global.postData.requestDateTime = new Date().format('yyyy-MM-dd hh:mm:ss');
  },
  renderCallback: function () {

    /*时间插件渲染*/
    var dateDiv = $('#dateTimeDiv');
    dateDiv.find('.date-hour').each(function(){
      var time = new Date();
      time = new Date() - 1*3600*1000;
      layDate.render({ type: 'datetime', elem: this, format: 'yyyy年MM月dd日HH时', value: new Date(time).format('yyyy年MM月dd日hh时')});
    });
    dateDiv.find('.date-day').each(function(){
      var time = new Date();
      if ( $(this).hasClass('start-time') ) {
          if(Global.dataEnv == "Forecast"){
            time = new Date() - 1*24*3600*1000;
          }else{
            time = new Date() - 7*24*3600*1000;
          }
      }
      if ( $(this).hasClass('end-time') ) {
        time = new Date() - 1*24*3600*1000;
      }
      layDate.render({elem: this, format: 'yyyy年MM月dd日', value: new Date(time).format('yyyy年MM月dd日')});
    });

    var weekOfYear =  dateTime.getWeekOfYear();
    var lastWeek = weekOfYear == 1 ? weekOfYear : weekOfYear -1;
    var lastWeekInt = lastWeek;
    lastWeek = lastWeek < 10 ? "0"+lastWeek : lastWeek;
    
    dateDiv.find('.start-time-week').parent().find(".layui-form-select").find(".layui-input").val(lastWeekInt+"周");
    dateDiv.find('.start-time-week').eq(0).val(lastWeek);
    dateDiv.find('.end-time-week').parent().find(".layui-form-select").find(".layui-input").val(lastWeekInt+"周");
    dateDiv.find('.end-time-week').eq(0).val(lastWeek);
    dateDiv.find('.date-month').each(function(){
      layDate.render({elem: this, type: 'month', format: 'yyyy年MM月', value: new Date().format('yyyy年MM月')});
    });
    dateDiv.find('.date-year').each(function(){
      layDate.render({elem: this, type: 'year', format: 'yyyy年', value: new Date().format('yyyy年')});
    });
    /*历史统计时间*/
    layDate.render({
      elem: '#historyDate',
      type: 'year',
      range: true,
      value: '1951 - ' + new Date().getFullYear()
    });
    layDate.render({
      elem: '#normalDate',
      type: 'year',
      range: true,
      value: '1981 - 2010'
    });


    /*切换时间选项*/
    layForm.on('select(timeTypeSelect)', function (data) {
      /*显示相应的日期选择*/
      $('#dateTimeDiv').children(':not(.time-type)').hide().siblings('.' + data.value).show();
    });




  },
  timeTemplate: {
    /*时选择*/
    hourTimeString: function() {
      var display = Global.currElementObj.timeTypeArray[0] === 'HourTimeType';

      var tem = timeString({label: '开始日期:', displayType: 'block', display: display, className: 'HourTimeType pluginsSingleRows',
        templateArray: ["<input class='layui-input date-hour start-time-hour input-start-time' type=\"text\"/>"]});

      tem += timeString({label: '结束日期:', displayType: 'block', display: display, className: 'HourTimeType pluginsSingleRows',
        templateArray: ["<input class='layui-input date-hour end-time-hour input-end-time' type=\"text\"/>"]});

      return tem;
    },

    /*日选择*/
    dayTimeString: function() {
      var tem = timeString({label: '开始日期:', displayType: 'block', display: Global.currElementObj.timeTypeArray[0] === 'DayTimeType', className: 'DayTimeType pluginsSingleRows',
        templateArray: ["<input class='layui-input date-day start-time  input-start-time' type=\"text\"/>"]});
        if(Global.layName=="生育期气象适宜度预报" || Global.layName=="农事活动气象适宜度预报" || Global.layName=="灾害预测" ){
            tem += timeString({label: '结束日期:', displayType: 'block', display: Global.currElementObj.timeTypeArray[0] === 'none', className: 'DayTimeType pluginsSingleRows',
                templateArray: ["<input class='layui-input date-day end-time  input-end-time' type=\"text\"/>"]});
        } else{
            tem += timeString({label: '结束日期:', displayType: 'block', display: Global.currElementObj.timeTypeArray[0] === 'DayTimeType', className: 'DayTimeType pluginsSingleRows',
                templateArray: ["<input class='layui-input date-day end-time  input-end-time' type=\"text\"/>"]});
        }
      // tem += timeString({label: '结束日期:', displayType: 'block', display: Global.currElementObj.timeTypeArray[0] === 'DayTimeType', className: 'DayTimeType pluginsSingleRows',
      //   templateArray: ["<input class='layui-input date-day end-time  input-end-time' type=\"text\"/>"]});

      return tem;
    },

    weekTimeString : function(){
      var tem = '',
        weekOption = '';

      for ( var j = 1; j < 52; j++ ) {
        weekOption += '<option value="'+ ( j > 9 ? j : '0'+j ) +'">'+ j +'周</option>';
      }

      tem += timeString({label: '开始日期:', displayType: 'inline', display: Global.currElementObj.timeTypeArray[0] === 'WeekTimeType', className: 'WeekTimeType pluginsSingleRows',
        templateArray:["<input class='layui-input date-year start-time-year  input-start-time' type=\"text\"/>",
        '<select class="start-time-week">'+ weekOption +'</select>']});
      tem += timeString({label: '结束日期:', displayType: 'inline', display: Global.currElementObj.timeTypeArray[0] === 'WeekTimeType', className: 'WeekTimeType pluginsSingleRows',
        templateArray:["<input class='layui-input date-year end-time-year input-end-time' type=\"text\"/>",
        '<select class="end-time-week">'+ weekOption +'</select>']});

      return tem;
    },
    /*候日期选择*/
    houTimeString: function() {
      var tem = '',
        houOption = '';

      for ( var j = 1; j < 73; j++ ) {
        houOption += '<option value="'+ ( j > 9 ? j : '0'+j ) +'">'+ j +'候</option>';
      }

      tem += timeString({label: '开始日期:', displayType: 'inline', display: Global.currElementObj.timeTypeArray[0] === 'HouTimeType', className: 'HouTimeType pluginsSingleRows',
        templateArray:["<input class='layui-input date-year start-time-year  input-start-time' type=\"text\"/>",
        '<select class="start-time-hou">'+ houOption +'</select>']});
      tem += timeString({label: '结束日期:', displayType: 'inline', display: Global.currElementObj.timeTypeArray[0] === 'HouTimeType', className: 'HouTimeType pluginsSingleRows',
        templateArray:["<input class='layui-input date-year end-time-year input-end-time' type=\"text\"/>",
        '<select  class="end-time-hou">'+ houOption +'</select>']});

      return tem;
    },

    /*旬日期选择*/
    tenTimeString: function() {
      var tem = '',
        tenOption = '';
      ['上旬', '中旬', '下旬'].forEach(function (val, ind) {
        tenOption += '<option value="0'+ (ind+1) +'">'+ val +'</option>';
      });
      tem += timeString({label: '开始日期:', displayType: 'inline', display: Global.currElementObj.timeTypeArray[0] === 'TenDaysTimeType', className: 'TenDaysTimeType pluginsSingleRows',
        templateArray:["<input class='layui-input date-month start-time-month input-start-time' type=\"text\"/>",
        '<select class="start-time-ten">'+ tenOption +'</select>']});
      tem += timeString({label: '结束日期:', displayType: 'inline', display: Global.currElementObj.timeTypeArray[0] === 'TenDaysTimeType', className: 'TenDaysTimeType pluginsSingleRows',
        templateArray:["<input class='layui-input date-month end-time-month input-end-time' type=\"text\"/>",
        '<select class="end-time-ten">'+ tenOption +'</select>']});

      return tem;
    },

    /*月日期选择*/
    monthTimeString: function() {

      var tem = timeString({label: '开始日期:', displayType: 'block', display: Global.currElementObj.timeTypeArray[0] === 'MonthTimeType', className: 'MonthTimeType pluginsSingleRows',
        templateArray: ["<input class='layui-input date-month start-time-month  input-start-time' type=\"text\"/>"]});

      tem += timeString({label: '结束日期:', displayType: 'block', display: Global.currElementObj.timeTypeArray[0] === 'MonthTimeType', className: 'MonthTimeType pluginsSingleRows',
        templateArray: ["<input class='layui-input date-month end-time-month  input-end-time' type=\"text\"/>"]});

      return tem;
    },

    /*季日期选择*/
    seasonTimeString: function() {

      var seasonOption = '';
      ['春季', '夏季', '秋季', '冬季'].forEach(function (val, ind) {
        seasonOption += '<option value="0'+ (ind+1) +'">'+ val +'</option>';
      });

      var tem = timeString({label: '开始日期:', displayType: 'inline', display: Global.currElementObj.timeTypeArray[0] === 'SeasonTimeType', className: 'SeasonTimeType pluginsSingleRows',
        templateArray:["<input class='layui-input date-year start-time-year input-start-time ' type=\"text\"/>",
        '<select class="start-time-season">'+ seasonOption +'</select>']});

      tem += timeString({label: '结束日期:', displayType: 'inline', display: Global.currElementObj.timeTypeArray[0] === 'SeasonTimeType', className: 'SeasonTimeType pluginsSingleRows',
        templateArray:["<input class='layui-input date-year end-time-year input-end-time ' type=\"text\"/>",
        '<select class="end-time-season">'+ seasonOption +'</select>']});

      return tem;
    },

    /*年日期选择*/
    yearTimeString: function() {

      var tem = timeString({label: '开始日期:', displayType: 'block', display: Global.currElementObj.timeTypeArray[0] === 'YearTimeType', className: 'YearTimeType pluginsSingleRows',
        templateArray: ["<input class='layui-input date-year start-time-year input-start-time' type=\"text\"/>"]});

      tem += timeString({label: '结束日期:', displayType: 'block', display: Global.currElementObj.timeTypeArray[0] === 'YearTimeType', className: 'YearTimeType pluginsSingleRows',
        templateArray: ["<input class='layui-input date-year end-time-year input-end-time' type=\"text\"/>"]});

      return tem;
    },
    /**失效选择 */
    validTimeString : function(){
      var validTimeHtml="<div class=\"pluginsSingleRows time-type layui-form-item\">" +
        "<label class='layui-form-label'>选择时效:</label>" +
        "<div class='layui-input-block'>" +
        "<select lay-filter='validSelect' id='validSelect'>";
      
      for(var i=1;i<=7;i++){
         var validName = "";
         if(i == 1) validName = "明天";
         if(i == 2) validName = "后天";
         if(i >=3){
          var dateTime=new Date();
          dateTime=dateTime.setDate(dateTime.getDate()+i);
          dateTime=new Date(dateTime);
          validName = (dateTime.getMonth()+1) + "月"+ dateTime.getDate()+"日";
         }
         validTimeHtml+="<option value=\""+(24*i)+"\"  >未来"+ (24*i) +"小时</option>";
      }
      validTimeHtml+="</select></div></div>";
      return validTimeHtml;
    }

}

};


/*时间模板layui插件
  * label 名称，
  * displayType 显示方式，
  * display 是否显示，
  * className类名，
  * templateArray 输入框下拉框内容*/
function timeString(param) {
  var content = param.templateArray.map(function (val) {
    return "<div class='layui-input-"+ param.displayType +"'>" + val + "</div>"
  }).join('');
  return '<div style="'+ (param.display ? '' : 'display: none;') +'" ' +
    'class="'+ param.className +' layui-form-item">' +
    "<label class='layui-form-label'>"+ param.label +"</label>" + content + "</div>"
}
